home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1995 / MacHack 1995.toast / Presentations / Presentations ’92 / Graphics Acceleration Samples / Sample.h < prev    next >
Text File  |  1991-06-11  |  9KB  |  201 lines

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware Simple Sample Application
  6. #
  7. #    Sample
  8. #
  9. #    Sample.h    -    Rez and C Include Source
  10. #
  11. #    Copyright © 1988 Apple Computer, Inc.
  12. #    All rights reserved.
  13. #
  14. #    Versions:    1.0                    08/88
  15. #                1.01                11/88
  16. #
  17. #    Components:    Sample.p            November 1, 1988
  18. #                Sample.c            November 1, 1988
  19. #                Sample.a            November 1, 1988
  20. #                Sample.inc1.a        November 1, 1988
  21. #                SampleMisc.a        November 1, 1988
  22. #                Sample.r            November 1, 1988
  23. #                Sample.h            November 1, 1988
  24. #                [P]Sample.make        November 1, 1988
  25. #                [C]Sample.make        November 1, 1988
  26. #                [A]Sample.make        November 1, 1988
  27. #
  28. #    Sample is an example application that demonstrates how to
  29. #    initialize the commonly used toolbox managers, operate 
  30. #    successfully under MultiFinder, handle desk accessories, 
  31. #    and create, grow, and zoom windows.
  32. #
  33. #    It does not by any means demonstrate all the techniques 
  34. #    you need for a large application. In particular, Sample 
  35. #    does not cover exception handling, multiple windows/documents, 
  36. #    sophisticated memory management, printing, or undo. All of 
  37. #    these are vital parts of a normal full-sized application.
  38. #
  39. #    This application is an example of the form of a Macintosh 
  40. #    application; it is NOT a template. It is NOT intended to be 
  41. #    used as a foundation for the next world-class, best-selling, 
  42. #    600K application. A stick figure drawing of the human body may 
  43. #    be a good example of the form for a painting, but that does not 
  44. #    mean it should be used as the basis for the next Mona Lisa.
  45. #
  46. #    We recommend that you review this program or TESample before 
  47. #    beginning a new application.
  48. ------------------------------------------------------------------------------*/
  49.  
  50. /*    These #defines correspond to values defined in the Pascal source code.
  51.     Sample.c and Sample.r include this file. */
  52.  
  53. /*    Determining an application's minimum size to request from MultiFinder depends
  54.     on many things, each of which can be unique to an application's function,
  55.     the anticipated environment, the developer's attitude of what constitutes
  56.     reasonable functionality and performance, etc. Here is a list of some things to
  57.     consider when determining the minimum size (and preferred size) for your
  58.     application. The list is pretty much in order of importance, but by no means
  59.     complete.
  60.     
  61.     1.    What is the minimum size needed to give almost 100 percent assurance
  62.         that the application won't crash because it ran out of memory? This
  63.         includes not only things that you do have direct control over such as
  64.         checking for NIL handles and pointers, but also things that some
  65.         feel are not so much under their control such as QuickDraw and the
  66.         Segment Loader.
  67.         
  68.     2.    What kind of performance can a user expect from the application when
  69.         it is running in the minimum memory configuration? Performance includes
  70.         not only speed in handling data, but also things like how many documents
  71.         can be opened, etc.
  72.         
  73.     3.    What are the typical sizes of scraps is a boy dog that a user might
  74.         wish to work with when lauching or switching to your application? If
  75.         the amount of memory is too small, scraps will have to be shot. This
  76.         can be quite frustrating to the user.
  77.         
  78.     4.    The previous items have concentrated on topics that tend to cause an
  79.         increase in the minimum size to request from MultiFinder. On the flip
  80.         side, however, should be the consideration of what environments the
  81.         application may be running in. There may be a high probability that
  82.         many users with relatively small memory configurations will want to
  83.         avail themselves of your application. Or, many users might want to use it
  84.         while several other, possibly related/complementary applications are
  85.         running. If that is the case, it would be helpful to have a fairly
  86.         small minimum size.
  87.     
  88.     So, what did we decide on Sample? First, Sample has little risk of
  89.     running out of memory once it starts. Second, performance isn't much
  90.     of an issue since it doesn't do much and multiple windows are not
  91.     allowed. Third, there are no edit operations in Sample itself, so we
  92.     just want to provide enough space for a reasonable scrap to survive
  93.     between desk accessory launches. Lastly, Sample should intrude as little
  94.     as possible, so the effort should be towards making it as small as possible.
  95.     We looked at some heap dumps while the application was running under
  96.     various partition sizes. With a size of 23K, there was approximately
  97.     8-9K free, which is a good 'slop' factor in an application like this
  98.     which doesn't do much, but where we'd still like the scrap to survive
  99.     most of the time. */
  100.  
  101. #define kMinSize    1000            /* application's minimum size (in K) */
  102.  
  103. /*    We made the preferred size bigger than the minimum size by 12K, so that
  104.     there would be even more room for the scrap, FKEYs, etc. */
  105.  
  106. #define kPrefSize    4000            /* application's preferred size (in K) */
  107.  
  108. #define    rMenuBar    128                /* application's menu bar */
  109. #define    rAboutAlert    128                /* about alert */
  110. #define    rUserAlert    129                /* error user alert */
  111. #define    rWindow        128                /* application's window */
  112. #define    rVScroll    128                /* vertical scrollbar control */
  113. #define    rHScroll    129                /* horizontal scrollbar control */
  114.  
  115. /* kSysEnvironsVersion is passed to SysEnvirons to tell it which version of the
  116.    SysEnvRec we understand. */
  117.  
  118. #define    kSysEnvironsVersion        1
  119.  
  120. /* kOSEvent is the event number of the suspend/resume and mouse-moved events sent
  121.    by MultiFinder. Once we determine that an event is an osEvent, we look at the
  122.    high byte of the message sent to determine which kind it is. To differentiate
  123.    suspend and resume events we check the resumeMask bit. */
  124.  
  125. #define    kOSEvent                app4Evt    /* event used by MultiFinder */
  126. #define    kSuspendResumeMessage    1        /* high byte of suspend/resume event message */
  127. #define    kResumeMask                1        /* bit of message field for resume vs. suspend */
  128. #define    kMouseMovedMessage        0xFA    /* high byte of mouse-moved event message */
  129.  
  130. /* The following constants are used to identify menus and their items. The menu IDs
  131.    have an "m" prefix and the item numbers within each menu have an "i" prefix. */
  132.  
  133. #define    mApple                    128        /* Apple menu */
  134. #define    iAbout                    1
  135.  
  136. #define    mFile                    129        /* File menu */
  137. #define    iOpen                    2
  138. #define    iClose                    4
  139. #define    iQuit                    12
  140.  
  141. #define    mEdit                    130        /* Edit menu */
  142. #define    iUndo                    1
  143. #define    iCut                    3
  144. #define    iCopy                    4
  145. #define    iPaste                    5
  146. #define    iClear                    6
  147.  
  148. #define    mOptions                131        /* Edit menu */
  149. #define    iConvolve                1
  150.  
  151. /*    kScrollbarAdjust and kScrollbarWidth are used in calculating
  152.     values for control positioning and sizing. */
  153. #define kScrollbarWidth            16
  154. #define kScrollbarAdjust        (kScrollbarWidth - 1)
  155. #define kControlInvisible        0
  156. #define kControlVisible            0xFF
  157. #define kScrollTweek            2
  158.  
  159. /*    1.01 - kMinHeap - This is the minimum result from the following
  160.     equation:
  161.         
  162.         ORD(GetApplLimit) - ORD(ApplicZone)
  163.         
  164.     for the application to run. It will insure that enough memory will
  165.     be around for reasonable-sized scraps, FKEYs, etc. to exist with the
  166.     application, and still give the application some 'breathing room'.
  167.     To derive this number, we ran under a MultiFinder partition that was
  168.     our requested minimum size, as given in the 'SIZE' resource. */
  169.      
  170. #define kMinHeap                (21 * 1024)
  171.     
  172. /*    1.01 - kMinSpace - This is the minimum result from PurgeSpace, when called
  173.     at initialization time, for the application to run. This number acts
  174.     as a double-check to insure that there really is enough memory for the
  175.     application to run, including what has been taken up already by
  176.     pre-loaded resources, the scrap, code, and other sundry memory blocks. */
  177.      
  178. #define kMinSpace                (8 * 1024)
  179.  
  180. /* kExtremeNeg and kExtremePos are used to set up wide open rectangles and regions. */
  181.  
  182. #define kExtremeNeg                -32768
  183. #define kExtremePos                (32767 - 1) /* required to address an old region bug */
  184.  
  185. /* these #defines are used to set enable/disable flags of a menu */
  186.  
  187. #define AllItems    0b1111111111111111111111111111111    /* 31 flags */
  188. #define NoItems        0b0000000000000000000000000000000
  189. #define MenuItem1    0b0000000000000000000000000000001
  190. #define MenuItem2    0b0000000000000000000000000000010
  191. #define MenuItem3    0b0000000000000000000000000000100
  192. #define MenuItem4    0b0000000000000000000000000001000
  193. #define MenuItem5    0b0000000000000000000000000010000
  194. #define MenuItem6    0b0000000000000000000000000100000
  195. #define MenuItem7    0b0000000000000000000000001000000
  196. #define MenuItem8    0b0000000000000000000000010000000
  197. #define MenuItem9    0b0000000000000000000000100000000
  198. #define MenuItem10    0b0000000000000000000001000000000
  199. #define MenuItem11    0b0000000000000000000010000000000
  200. #define MenuItem12    0b0000000000000000000100000000000
  201.